<HTML>
<HEAD>
<TITLE>
AutumnException.h
</TITLE>
</HEAD>
<BODY>
<PRE>
<font color="green">/*
* Copyright 2006 the original author or authors.
* 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
*      http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/</font>

<font color="blue">#ifndef</font> AUTUMN_EXCEPTION_H
<font color="blue">#define</font> AUTUMN_EXCEPTION_H

<font color="blue">#include</font> <font color="maroon">&#60;exception&#62;</font>
<font color="blue">#include</font> <font color="maroon">&#60;string&#62;</font>
<font color="blue">#include</font> <font color="maroon">"AutumnLog.h"</font>

<font color="blue">using</font> <font color="blue">namespace</font> std;
<font color="green">/** 
 * The exceptions used in AutumnFramework
 * @version 0.1.0
 * @since 2006-11-30
 */</font>

<font color="blue">namespace</font> Autumn<font color="black">{</font>

<font color="green">/**  
 * AutumnFramework's root exception
 */</font>
<font color="blue">class</font> AutumnException<font color="black">:</font> <font color="blue">public</font> exception<font color="black">{</font>

    <font color="green">/** The class where exception happened. */</font>
    string ClassName;

    <font color="green">/** The method where exception happened. */</font>
    string MethodName;

    <font color="green">/** The cause of exception */</font>
    string ErrMessage;

    <font color="green">/** whole message */</font>
    string WholeMessage;

<font color="blue">public</font><font color="black">:</font>
    <font color="green">/** 
     * Constructor with class name, method name and cause.
     */</font>
    AutumnException<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> cname, <font color="blue">const</font> string<font color="black">&</font> mname,
                    <font color="blue">const</font> string<font color="black">&</font> msg<font color="black">)</font><font color="black">:</font>
        ClassName<font color="black">(</font>cname<font color="black">)</font>,MethodName<font color="black">(</font>mname<font color="black">)</font>,ErrMessage<font color="black">(</font>msg<font color="black">)</font><font color="black">{</font>

        <font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>WholeMessage <font color="black">=</font> cname <font color="black">+</font> <font color="maroon">"-&#62;"</font> <font color="black">+</font> mname <font color="black">+</font> <font color="maroon">": "</font> <font color="black">+</font> msg;
        AutumnLog<font color="black">:</font><font color="black">:</font>getInstance<font color="black">(</font><font color="black">)</font><font color="black">-</font><font color="black">&#62;</font><font color="blue">error</font><font color="black">(</font><font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>WholeMessage.c_str<font color="black">(</font><font color="black">)</font><font color="black">)</font>;
    <font color="black">}</font>
    
    <font color="green">/** Destructor. Solaris need this */</font>
    virtual ~AutumnException<font color="black">(</font><font color="black">)</font> <font color="blue">throw</font><font color="black">(</font><font color="black">)</font> <font color="black">{</font><font color="black">}</font>

    <font color="green">/** The method derived from system exception class */</font>
    virtual <font color="blue">const</font> <font color="blue">char</font><font color="black">*</font> what<font color="black">(</font><font color="black">)</font> <font color="blue">const</font> <font color="blue">throw</font><font color="black">(</font><font color="black">)</font><font color="black">{</font>
        <font color="blue">return</font> <font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>WholeMessage.c_str<font color="black">(</font><font color="black">)</font>;
    <font color="black">}</font>
<font color="black">}</font>;

<font color="green">/** Exception happened while initializing bean configuration*/</font>
<font color="blue">class</font> InitException<font color="black">:</font> <font color="blue">public</font> AutumnException<font color="black">{</font>
<font color="blue">public</font><font color="black">:</font>
    InitException<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> cname, <font color="blue">const</font> string<font color="black">&</font> mname, <font color="blue">const</font> string<font color="black">&</font> msg<font color="black">)</font><font color="black">:</font>
      AutumnException<font color="black">(</font>cname, mname, msg<font color="black">)</font><font color="black">{</font>
      <font color="black">}</font>

<font color="black">}</font>;

<font color="green">/** Exception happened while injecting beans */</font>
<font color="blue">class</font> InjectionException<font color="black">:</font> <font color="blue">public</font> AutumnException<font color="black">{</font>
<font color="blue">public</font><font color="black">:</font>
    InjectionException<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> cname, <font color="blue">const</font> string<font color="black">&</font> mname, <font color="blue">const</font> string<font color="black">&</font> msg<font color="black">)</font><font color="black">:</font>
      AutumnException<font color="black">(</font>cname, mname, msg<font color="black">)</font><font color="black">{</font>
      <font color="black">}</font>
<font color="black">}</font>;

<font color="green">/** Exception of not having something definition */</font>
<font color="blue">class</font> MissDefinitionEx<font color="black">:</font> <font color="blue">public</font> InitException<font color="black">{</font>
<font color="blue">public</font><font color="black">:</font>
    MissDefinitionEx<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> cname, <font color="blue">const</font> string<font color="black">&</font> mname,
                    <font color="blue">const</font> string<font color="black">&</font> msg<font color="black">)</font><font color="black">:</font>
      InitException<font color="black">(</font>cname, mname, msg<font color="black">)</font><font color="black">{</font>
      <font color="black">}</font>
<font color="black">}</font>;

<font color="green">/** Exception of having non value */</font>
<font color="blue">class</font> NonValueEx<font color="black">:</font> <font color="blue">public</font> InitException<font color="black">{</font>
<font color="blue">public</font><font color="black">:</font>
    NonValueEx<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> cname, <font color="blue">const</font> string<font color="black">&</font> mname, <font color="blue">const</font> string<font color="black">&</font> msg<font color="black">)</font><font color="black">:</font>
      InitException<font color="black">(</font>cname, mname, msg<font color="black">)</font><font color="black">{</font>
      <font color="black">}</font>
<font color="black">}</font>;

<font color="green">/** Exception of having non instance */</font>
<font color="blue">class</font> NonInstanceEx<font color="black">:</font> <font color="blue">public</font> InitException<font color="black">{</font>
<font color="blue">public</font><font color="black">:</font>
    NonInstanceEx<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> cname, <font color="blue">const</font> string<font color="black">&</font> mname, <font color="blue">const</font> string<font color="black">&</font> msg<font color="black">)</font><font color="black">:</font>
      InitException<font color="black">(</font>cname, mname, msg<font color="black">)</font><font color="black">{</font>
      <font color="black">}</font>
<font color="black">}</font>;

<font color="green">/** Exception of not found the object operated on */</font>
<font color="blue">class</font> NotFoundEx<font color="black">:</font> <font color="blue">public</font> InitException<font color="black">{</font>
<font color="blue">public</font><font color="black">:</font>
    NotFoundEx<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> cname, <font color="blue">const</font> string<font color="black">&</font> mname, <font color="blue">const</font> string<font color="black">&</font> msg<font color="black">)</font><font color="black">:</font>
      InitException<font color="black">(</font>cname, mname, msg<font color="black">)</font><font color="black">{</font>
      <font color="black">}</font>
<font color="black">}</font>;

<font color="green">/** Reduplicate definition */</font>
<font color="blue">class</font> ReduplicateEx<font color="black">:</font> <font color="blue">public</font> InitException<font color="black">{</font>
<font color="blue">public</font><font color="black">:</font>
    ReduplicateEx<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> cname, <font color="blue">const</font> string<font color="black">&</font> mname, <font color="blue">const</font> string<font color="black">&</font> msg<font color="black">)</font><font color="black">:</font>
      InitException<font color="black">(</font>cname, mname, msg<font color="black">)</font><font color="black">{</font>
      <font color="black">}</font>
<font color="black">}</font>;

<font color="green">/** Parsing XML file error */</font>
<font color="blue">class</font> XMLParsingEx<font color="black">:</font> <font color="blue">public</font> InitException<font color="black">{</font>
<font color="blue">public</font><font color="black">:</font>
    XMLParsingEx<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> cname, <font color="blue">const</font> string<font color="black">&</font> mname, <font color="blue">const</font> string<font color="black">&</font> msg<font color="black">)</font><font color="black">:</font>
      InitException<font color="black">(</font>cname, mname, msg<font color="black">)</font><font color="black">{</font>
      <font color="black">}</font>
<font color="black">}</font>;

<font color="green">/** Create bean failed */</font>
<font color="blue">class</font> CreateBeanFailedEx<font color="black">:</font> <font color="blue">public</font> InjectionException<font color="black">{</font>
<font color="blue">public</font><font color="black">:</font>
    CreateBeanFailedEx<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> cname, <font color="blue">const</font> string<font color="black">&</font> mname, 
                       <font color="blue">const</font> string<font color="black">&</font> msg<font color="black">)</font><font color="black">:</font>
      InjectionException<font color="black">(</font>cname, mname, msg<font color="black">)</font><font color="black">{</font>
      <font color="black">}</font>
<font color="black">}</font>;

<font color="green">/** Create bean failed */</font>
<font color="blue">class</font> SetPropertyFailedEx<font color="black">:</font> <font color="blue">public</font> InjectionException<font color="black">{</font>
<font color="blue">public</font><font color="black">:</font>
    SetPropertyFailedEx<font color="black">(</font><font color="blue">const</font> string<font color="black">&</font> cname, <font color="blue">const</font> string<font color="black">&</font> mname,
                        <font color="blue">const</font> string<font color="black">&</font> msg<font color="black">)</font><font color="black">:</font>
      InjectionException<font color="black">(</font>cname, mname, msg<font color="black">)</font><font color="black">{</font>
      <font color="black">}</font>
<font color="black">}</font>;

<font color="black">}</font> <font color="green">// End namespace Autumn</font>
<font color="blue">#endif</font>


</PRE>
</BODY>
</HTML>
